package com.xjc.market.acct.biz;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.xjc.infra.exception.IFSException;
import com.xjc.market.acct.entity.table.AcMenu;
import com.xjc.market.acct.entity.table.AcOperator;
import com.xjc.market.acct.mapper.AcMenuMapper;
import com.xjc.market.acct.mapper.AcOperatorMapper;
import com.xjc.market.frame.base.BaseTBiz;

/**
 * 菜单-业务处理类
 * @author liangcz
 * @Date   2017年9月5日 下午5:27:38
 * @version 1.0
 */
@Transactional
@Service
public class MenuBiz extends BaseTBiz<AcMenu>{
	@Autowired
	AcMenuMapper acMenuMapper;
	@Autowired
	AcOperatorMapper acOperatorMapper;
	/**
	 * 查询菜单失败
	 * @author liangcz
	 * @date   2017年9月6日 下午2:57:34
	 * @return List<AcMenu>
	 */
	public List<AcMenu> inquiryMenu(String userid){
		try {
			AcOperator acOperator = acOperatorMapper.selectByUserId(userid);
			if(acOperator == null){
				throw new IFSException(null, "MenuBiz.inquiryMenu.01", "操作员不存在");
			}
			List<AcMenu> acMenuList = acMenuMapper.selectByRoleId(acOperator.getRoleId());
			return acMenuList;
		} catch (IFSException e) {
			throw e;
		} catch (Exception e) {
			throw new IFSException(e, "MenuBiz.inquiryMenu.99", "查询菜单失败");
		}
	}
}
